#include <stdio.h>
#include "types.h"
#include "stack.h"

typedef struct stack_t {
    i32 value;
    void *prev;
} stack_t;

void stack_print(stack_t *list) {
    printf("Stack contents:\n  ");
    stack_t *ptr = list;
    while(ptr) {
        printf("%d ", ptr->value);
        ptr = ptr->prev;
    }
    printf("\n");
}

int main(void) {
    stack_t *data = malloc(sizeof(*data));
    data->value = 0;
    data->prev = NULL;
    for (u8 i=1; i<=25; ++i) {
        push(data, i);
    }
    i32 value = -1;
    pop(data, &value);
    assert(value == 25 && "Failed to pop from stack.");
    stack_print(data);
    stack_free(data);
    assert(data == NULL && "Failed to empty stack.");
    return 0;
}